var con=new Vue({
    el:"#heard",
    data:{
        parentSidebars:[],
        sidebars:[],
        clickFlag:-1,
        user:{}
    },
    mounted(){
        this.quanxianInfo();
    },
    methods:{
        quanxianInfo(){
            axios({
                method:"post",
                url:"yly-api/admin/queryFunctionByPostId",
                headers:{"token":localStorage.token,"url":window.location.pathname}
            }).then(function (res) {
                console.log(res.data);
                if (res.data.data.code==200){
                    con.sidebars=res.data.data.data;
                    con.user=res.data.user;

                }else if (res.data.data.code==500){
                    location.href="500.html";
                }

            }).catch(function (error) {
                console.log(error.response.status);
                if (error.response.status==401){
                    alert("权限不足，无法访问!");
                    location.href="login.html";
                }else if (error.response.status==403){
                    alert("用户已过期，请重新登录！");
                    localStorage.token=null;
                    location.href="login.html";
                }
            })
        },
        addClass(index){
            this.clickFlag=index;
        },
        logout(){
            axios({
                method: "get",
                url:"yly-api/admin/logout",
                headers: {"token":localStorage.token,"url":window.location.pathname}
            }).then(function (res) {
                console.log(res.data);
                if (res.data=="success"){
                    alert("退出成功！");
                    localStorage.token=null;
                    location.href="login.html";
                }else {
                    alert("退出失败，请联系管理员！")
                }
            }).catch(function (error) {
                console.log(error.response.status);
                if (error.response.status==401){
                    alert("权限不足，无法访问!");
                    location.href="login.html";
                }else if (error.response.status==403){
                    alert("用户已过期，请重新登录！");
                    localStorage.token=null;
                    location.href="login.html";
                }
            })
        }
    }
});
